package com.zframeworks.core;

import com.zframeworks.core.bean.Code;
import com.zframeworks.core.bean.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class AdviceHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result Exceptions(Exception e){
        Result result = new Result();
        result.setCode(Code.ERROR);
        result.setMsg(e.getMessage());
        result.setData(z.exceptionToString(e));
        return result;
    }
}
